<h1>Iteration <%=h @iteration.iteration_number %></h1>
<p>Start Date: <%=h @iteration.start_date %></p>
<p>End Date: <%=h @iteration.end_date %></p>

<h2>Deliverables</h2>

<%=h @status %>

<br />
<br />

<i>
  <%= link_to "Add new deliverable", { :controller => :deliverables, 
    :action => :new, :schedulable_id =>@iteration.id,
    :schedulable_type => "Iteration" }, { :class => :command }
  %>
</i>

<br />
<br />

<table width = "75%" border = 1>
    <th></th>
    <th align="left">Release Name</th>
    <th align="left">Product Name</th>
    <th align="left">Feature Name</th>
    <th align="left">Deliverable description</th>
    <th align="left"><%= link_to "Resources", 
      { :id => @iteration.id,
        :action => :show, 
        :controller=> :iterations
      } %>
      </th>
    <th align="left">Status</th>
    <% deliverable_number = 1 %>

  <% for deliverable in @deliverables %>
  <tr>
    <td>
      <%= deliverable_number %>
    </td>
    <td>
      <%= deliverable.project.name unless !deliverable.project %>
    </td>
    <td>
      <%= deliverable.product.name unless !deliverable.product %>
    </td>
    <td>
      <%= deliverable.feature.name unless !deliverable.feature %>
    </td>
    <td>
      <%= link_to deliverable.description, {
            :controller => :deliverables,
            :action => :edit,
            :id => deliverable.id
            }, {
            :class => :data
            } %>
  </td>
  <td>
    <% for assignment in deliverable.assignments %>
      <%= link_to "#{Resource.format_name(assignment.resource.name)}", {
        :id => @iteration.id,
        :resource => assignment.resource.name, :controller => :iterations, 
        :action => :show
      } 
      %>
    <% end %>
  </td>
  <td>
    <% if deliverable.status == 'Complete' %>
      <b> <%=h deliverable.status %> </b>
      <% else %>
      <%=h deliverable.status %> 
    <% end %>
  </td>
</tr>
  <% deliverable_number = deliverable_number + 1  %>
  <% end %>

  <tr>
    <td>
      <%= deliverable_number %>
    </td>
    <td colspan="3"><i>
        <%= link_to "Add new deliverable", {
              :controller => :deliverables,
              :action => :new,
              :schedulable_id =>@iteration.id,
              :schedulable_type => "Iteration"
              }, {
              :class => :command 
              }%>
      </i></td>
</tr>

</table>
